package com.si.control.action;

import javax.swing.JOptionPane;

import com.si.ui.enumn.EConstant;

public class SetConstantAction implements IAction<EConstant, Object> {

	@Override
	public Object perform(final EConstant argument) throws Exception {
		Integer value = null;
		while(value == null) {
			try {
				final String str = JOptionPane.showInputDialog(null, "Enter value:");
				if(str == null) return null;
				value = Integer.valueOf(str);
			} catch(NumberFormatException e) {
				JOptionPane.showMessageDialog(null, "Invalid input. Please try again.");
			}
		}
		argument.setValue(value);
		return null;
	}
}
